package com.huzz.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.huzz.model.MenuModel;
import com.huzz.service.ISysMenuService;
import com.huzz.vo.MenuVO;
import com.huzz.util.body.JsonResult;
import com.huzz.util.body.ResultTool;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @Name 名称
 * @Description 描述
 * @Author 童年的纸飞机
 * @Since 2023-04-2023/4/27 16:48
 */
@Api(tags = "系统菜单模块 API")
@RestController
@RequestMapping("/api/menu")
public class SysMenuController {

    @Autowired
    private ISysMenuService menuService;

    @ApiOperation(value = "新建菜单")
    @PostMapping("/createMenu")
    public JsonResult<String> createMenu(@RequestBody @Validated MenuModel menuModel) {
        return ResultTool.response(menuService.createMenu(menuModel));
    }

    @ApiOperation(value = "查询菜单分页列表")
    @GetMapping("/findMenuListPage")
    public JsonResult<IPage<MenuVO>> findMenuListPage(@RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "10") Integer pageSize, MenuModel model) {
        return ResultTool.success(menuService.findMenuListPage(pageNum, pageSize, model));
    }
}
